home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 168 / library / gem.c < prev    next >
C/C++ Source or Header  |  1988-04-30  |  21KB  |  1,149 lines

  1. /* 
  2.  * the GEM library
  3.  * contains both AES and VDI stuff, though not all of it
  4.  */
  5.  
  6. #include "gem.h"
  7.  
  8. extern short    ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7;
  9. extern short    ii0, ii1, ii2, ii3, ii4, ii5, ii6, ii7, ii8, ii9,
  10.         ii10, ii11, ii12, ii13, ii14, ii15;
  11. extern short    io0, io1, io2, io3, io4, io5, io6, iox[40];
  12. extern short    pi0, pi1, pi2, pi3, pi4, pi5, pi6, pi7, pix[6];
  13. extern short    po0, po1, po2, po3, pox[12];
  14. extern short    *ai0, *ai1;
  15. extern short    *ao0;
  16. extern    short    *vdi0, *vdi1, *vdi2, *vdi3, *vdi4, *vdi5;
  17. extern short    *aes0, *aes1, *aes2, *aes3, *aes4, *aes5;
  18. extern short    global[16];
  19.  
  20. /* 
  21.  * the c runtime start up routine for GEM processes
  22.  * no argv argc stuff, no stdio (use TOS routines for file access)
  23.  *
  24.  * assumes a startup prg.s of
  25.  *    . _bstk 2048
  26.  *    . _estk 4
  27.  *    taa 7 6
  28.  *    lll 4 0
  29.  *    sgl _estk
  30.  *    lag _estk 7
  31.  *    jsr _cprg
  32.  * plus definitions for all the above externs
  33.  */
  34.  
  35. #define SETBLK    0x4A
  36. #define TERM    0x4C
  37.  
  38. _cprg(tpa) long tpa; {
  39.     int i;
  40.     long x, *lp;
  41.  
  42.     /* compute size of program, give memory back to TOS */
  43.     lp = tpa;
  44.     x = lp[3] + lp[5] + lp[7] + 0x100;
  45.     if (trap(1, SETBLK, 0, tpa, x))
  46.         appl_exit(-1);
  47.  
  48.     /* set up the aespb and vdipb arrays */
  49.     aes0 = &ct0;
  50.     aes1 = global;
  51.     aes2 = &ii0;
  52.     aes3 = &io0;
  53.     aes4 = &ai0;
  54.     aes5 = &ao0;
  55.     vdi0 = &ct0;
  56.     vdi1 = &ii0;
  57.     vdi2 = &pi0;
  58.     vdi3 = &io0;
  59.     vdi4 = &po0;
  60.  
  61.     /* init standard i/o */
  62.     _ioinit();
  63.     
  64.     /* run the program */
  65.     i = main();
  66.  
  67.     /* close up shop */
  68.     appl_exit(i);
  69. }
  70.  
  71. #define vdc(op,pi,ii,xx,yy) ct0=op;ct1=pi;ct2=ct4=0;ct3=ii;ct5=xx;ct6=yy;vdi()
  72.  
  73.  
  74. /* open virtual workstation */
  75.  
  76. v_opnvwk(in, h, out) 
  77. struct vdi_openin *in; 
  78. short *h; 
  79. struct vdi_openout *out; {
  80.     vdi0    = &ct0;
  81.     vdi1    = in;
  82.     vdi2    = &pi0;
  83.     vdi3    = out;
  84.     vdi4    = &(out->devicetyp);
  85.     vdc(100, 0, 11, 0, 1);
  86.     *h     = ct6;
  87.     vdi0    = &ct0;
  88.     vdi1    = &ii0;
  89.     vdi2    = &pi0;
  90.     vdi3    = &io0;
  91.     vdi4    = &po0;
  92. }
  93.  
  94. /* close virtual workstation */
  95.         
  96. v_clsvwk(h) short h; {
  97.     vdc(101, 0, 0, 0, h);
  98. }
  99.  
  100. v_clrwk(h) short h; {
  101.     vdc(3, 0, 0, 0, h);
  102. }
  103.  
  104. /* cursor control */
  105.  
  106. v_enter_cur(h) short h; {    /* enter cursor mode - shows cursor */
  107.     vdc(5, 0, 0, 3, h);
  108. }
  109.  
  110. v_exit_cur(h) short h; {    /* exit cursor mode - removes cursor */
  111.     vdc(5, 0, 0, 2, h);
  112. }
  113.  
  114. v_rvon(h) {             /* reverse video on - cursor text */
  115.     vdc(5, 0, 0, 13, h);
  116. }
  117.  
  118. v_rvoff(h) {            /* reverse video off - cursor text */
  119.     vdc(5, 0, 0, 14, h);
  120. }
  121.  
  122. v_curhome(h) {            /* home cursor */
  123.     vdc(5, 0, 0, 8, h);
  124. }
  125.  
  126. vs_curaddress(h, r, c) {     /* put cursor on row r (0-24) and col. c (0-79) */
  127.     ii0 = c;
  128.     ii1 = r;
  129.     vdc(5, 0, 2, 11, h);
  130. }
  131.  
  132. /* screen operations */
  133.  
  134. v_eeos(h) {            /* erase from cursor to end of screen */
  135.     vdc(5, 0, 0, 9, h);
  136. }
  137.  
  138. /* polymarkers */
  139.     
  140. v_pmarker(h, count, xy)    short xy[]; { /* plot markers at xy coords. passed */
  141.     vdi2 = xy;
  142.     vdc(7, count, 0, 0, h);
  143.     vdi2 = &pi0;
  144. }
  145.  
  146. vsm_color(h, color) {    /* sets the color that marker is plotted with */
  147.     return vdi_attr(h, 20, color); /* color: 0 - numcolors */
  148. }
  149.  
  150. vsm_height(h, height) {    /* set the height of plotted markers (not of type 1) */
  151.     pi0 = 0;
  152.     pi1 = height; /* height: in pels, 1 - maxy */
  153.     vdc(19, 1, 0, 0, h);
  154.     return po1;
  155. }
  156.  
  157. vsm_type(h, type) {    /* set marker type - returns type selected */
  158.     return vdi_attr(h, 18, type); /* type: 1 - nummarktyp */
  159. }
  160.  
  161. vqm_attributes(h, at) struct vdi_mattr *at; { /* query marker attributes */
  162.     vdi3 = at;
  163.     vdi4 = &(at->markwid);
  164.     vdc(36, 0, 0, 0, h);
  165.     vdi3 = &io0;
  166.     vdi4 = &po0;
  167. }
  168.  
  169. /* polylines */
  170.  
  171. v_pline(h, count, xy) short xy[]; { /* draw multi-segment line */
  172.     vdi2 = xy;
  173.     vdc(6, count, 0, 0, h);     /* count >= 2 */
  174.     vdi2 = &pi0;
  175. }
  176.  
  177. vsl_color(h, color) {    /* set line color - returns color selected */
  178.     return vdi_attr(h, 17, color);
  179. }
  180.  
  181. vsl_ends(h, begin, end)    { /* set line end styles */
  182.     ii0 = begin;
  183.     ii1 = end;
  184.     vdc(108, 0, 2, 0, h);
  185. }
  186.  
  187. vsl_type(h, type) {    /* set line type - returns type selected */
  188.     return vdi_attr(h, 15, type);
  189. }
  190.  
  191. vsl_udsty(h, pat) {    /* set user defined line type pattern */
  192.     vdi_attr(h, 113, pat); /* e.g. dash line type is: 0xFF00 */
  193. }
  194.  
  195. vsl_width(h, w) {    /* set line width - returns actual width */
  196.     pi0 = w;
  197.     vdc(16, 1, 0, 0, h);
  198.     return po0;
  199. }
  200.  
  201. vql_attributes(h, at) struct vdi_lattr *at; { /* query line attributes */
  202.     vdi3 = at;
  203.     vdi4 = &(at->linewid);
  204.     vdc(35, 0, 0, 0, h);
  205.     vdi3 = &io0;
  206.     vdi4 = &po0;
  207. }
  208.  
  209. /* text */
  210.  
  211. vst_alignment(h, hin, vin, hout, vout) 
  212. short *hout, *vout; {     /* set text alignment */
  213.     ii0 = hin;
  214.     ii1 = vin;
  215.     vdc(39, 0, 2, 0, h);
  216.     *hout = io0;
  217.     *vout = io1;
  218. }
  219.  
  220. vst_color(h, color) {    /* set text color - color selected returned */
  221.     return vdi_attr(h, 22, color);
  222. }
  223.  
  224. vst_effects(h, effects) { /* set text effects - effects selected returned */
  225.     return vdi_attr(h, 106, effects);
  226. }
  227.  
  228. /* set text height - absolute mode */
  229. vst_height(h, height, wch, hch, wcl, hcl) int *wch, *hch, *wcl, *hcl; {
  230.     pi0 = 0;
  231.     pi1 = height; /* height: distance from baseline to top of char. cell */
  232.     vdc(12, 1, 0, 0, h);
  233.     *wch = po0;
  234.     *hch = po1;
  235.     *wcl = po2;
  236.     *hcl = po3;
  237. }
  238.  
  239. vst_point(h, height) { /* set text height - points mode, height returned */
  240.     /* distance between baselines of two consecutive lines */
  241.     return vdi_attr(h, 107, height);
  242. }
  243.  
  244. vst_rotation(h, angle) { /* set baseline vector - angle selected returned */
  245.     return vdi_attr(h, 13, angle); /* angle expressed in .1s of a degree */
  246. }
  247.  
  248. vst_font(h, font) {    /* set font - returns font selected */
  249.     return vdi_attr(h, 21, font);
  250. }
  251.  
  252. vswr_mode(h, mode) {    /* set writing mode - mode selected returned */
  253.     return vdi_attr(h, 32, mode);
  254. }
  255.  
  256. v_curtext(h, s) char *s; {
  257.     _vdi_tcpy(5, 0, 12, h, s);
  258. }
  259.  
  260. v_gtext(h, x, y, s) char *s; {
  261.     pi0 = x;
  262.     pi1 = y;
  263.     _vdi_tcpy(8, 2, 0, h, s);
  264. }
  265.  
  266. _vdi_tcpy(op, pin, p5, h, s) char *s; {
  267.     short    *ip, tbuf[140];
  268.     int    i;
  269.  
  270.     vdi1 = tbuf;
  271.     for (ip = tbuf, i = 0; (i < 140) && (*s != '\0'); ++i) {
  272.         *ip++ = *s++;
  273.     }
  274.     vdc(op, pin, i, p5, h);
  275.     vdi1 = &ii0;
  276. }
  277.  
  278. vqt_attributes(h, at) struct vdi_tattr *at; { /* query text attributes */
  279.     vdi3 = at;
  280.     vdi4 = &(at->charwid);
  281.     vdc(38, 0, 0, 0, h);
  282.     vdi3 = &io0;
  283.     vdi4 = &po0;
  284. }
  285.  
  286. /* graphic primitives */
  287.  
  288. v_arc(h, x, y, r, sa, ea) { /* draw arc - portion of a circle */
  289.     ii0 = sa;    /* start angle - .1s of degree */
  290.     ii1 = ea;    /* end angle */
  291.     pi0 = x;    /* center - x coord. */
  292.     pi1 = y;    /* center - y coord. */
  293.     pi6 = r;    /* radius */
  294.     vdc(11, 4, 2, 2, h);
  295. }
  296.  
  297. v_bar(h, xy) int *xy; {    /* draw a bar (box) */
  298.     pi0 = *xy;
  299.     pi1 = *++xy;
  300.     pi2 = *++xy;
  301.     pi3 = *++xy;
  302.     vdc(11, 2, 0, 1, h);
  303. }
  304.  
  305. v_circle(h, x, y, r) {    /* draw a circle */
  306.     pi0 = x;
  307.     pi1 = y;
  308.     pi4 = r;
  309.     vdc(11, 3, 0, 4, h);
  310. }
  311.  
  312. v_contourfill(h, x, y, color) {    /* fill area enclosing x,y */
  313.     pi0 = x;
  314.     pi1 = y;
  315.     ii0 = color; /* color < 0: boundry of any color other than xy's */
  316.     vdc(103, 1, 1, 0, h);
  317. }
  318.  
  319. v_ellarc(h, x, y, xr, yr, sa, ea) { /* draw an elliptical arc */
  320.     ii0 = sa;    /* start angle */
  321.     ii1 = ea; /* end angle */
  322.     pi0 = x;    /* center point x */
  323.     pi1 = y;    /* center point y */
  324.     pi2 = xr; /* x radius */
  325.     pi3 = yr; /* y radius */
  326.     vdc(11, 2, 2, 6, h);
  327. }
  328.  
  329. v_ellpie(h, x, y, xr, yr, sa, ea) { /* draw an elliptical pie slice */
  330.     ii0 = sa;
  331.     ii1 = ea;
  332.     pi0 = x;
  333.     pi1 = y;
  334.     pi2 = xr;
  335.     pi3 = yr;
  336.     vdc(11, 2, 2, 7, h);
  337. }
  338.  
  339. v_ellipse(h, x, y, xr, yr) {    /* draw an ellipse */
  340.     pi0 = x;
  341.     pi1 = y;
  342.     pi2 = xr;
  343.     pi3 = yr;
  344.     vdc(11, 2, 0, 5, h);
  345. }
  346.  
  347. v_rbox(h, xy) short *xy; { /* draw a rounded box */
  348.     pi0 = *xy; /* xy coordinates of lower left and upper right corners */
  349.     pi1 = *++xy;
  350.     pi2 = *++xy;
  351.     pi3 = *++xy;
  352.     vdc(11, 2, 0, 8, h);
  353. }
  354.  
  355. v_rfbox(h, xy) short *xy; { /* draw a rounded filled box */
  356.     pi0 = *xy; /* xy coordinates of lower left and upper right corners */
  357.     pi1 = *++xy;
  358.     pi2 = *++xy;
  359.     pi3 = *++xy;
  360.     vdc(11, 2, 0, 9, h);
  361. }
  362.  
  363. v_recfl(h, xy) short *xy; { /* draw a filled rectangle */
  364.     pi0 = *xy; /* xy coordinates of diagonally opposite corners */
  365.     pi1 = *++xy;
  366.     pi2 = *++xy;
  367.     pi3 = *++xy;
  368.     vdc(114, 2, 0, 0, h);
  369. }
  370.  
  371. /* area fill and attributes */
  372.  
  373. v_fillarea(h, count, xy) short xy[]; { 
  374.     vdi2 = xy; /* fill area defined by a multi-segment line */
  375.     vdc(9, count, 0, 0, h); /* count >= 2 */
  376.     vdi2 = &pi0;
  377. }
  378.  
  379. vsf_color(h, color) {    /* set fill color */
  380.     return vdi_attr(h, 25, color);
  381. }
  382.  
  383. vsf_perimeter(h, v_flag) { /* set fill perimeter visibility */
  384.     return vdi_attr(h, 104, v_flag); /* 0 = invisible, 1 = visible */
  385. }
  386.  
  387. vsf_interior(h, style) { /* set fill interior style */
  388.     return vdi_attr(h, 23, style);
  389. }
  390.  
  391. vsf_style(h, style) {    /* set fill style */
  392.     /* interior pattern: 0-23, interior hatch: 0-11 */
  393.     return vdi_attr(h, 24, style); 
  394. }
  395.  
  396. vsf_updat(h, fill, planes) int *fill; { /* set user defined fill pattern */
  397.     int n;
  398.     n = planes << 4; /* 16 words per plane */
  399.     vdi1 = fill;
  400.     vdc(112, 0, n, 0, h);
  401.     vdi1 = &ii0;
  402. }
  403.  
  404. vqf_attributes (h, at)    struct vdi_fattr *at; {
  405.     /* inquire current fill area attributes */
  406.     vdi4 = at;
  407.     vdc(37, 0, 0, 0, h);
  408.     vdi4 = &po0;
  409. }
  410.  
  411. /* pixel operation */
  412.  
  413. v_get_pixel(h, x, y, pel, color) short *pel, *color; { /* get pixel value */
  414.     pi0 = x;
  415.     pi1 = y;
  416.     vdc(105, 1, 0, 0, h);
  417.     *pel = io0;
  418.     *color = io1;
  419. }
  420.  
  421. vro_cpyfm(h, mode, xy, src, des) short xy[]; struct mfdb *src, *des; {
  422.     struct    mfdb    **p;
  423.  
  424.     p = (struct mfdb **) &ct7;
  425.     *p = src;
  426.     *++p = des;
  427.     ii0 = mode;
  428.     vdi2 = xy;
  429.     vdc(109, 4, 1, 0, h);
  430.     vdi2 = &pi0;
  431. }
  432.  
  433. vrt_cpyfm(h, mode, pxy, src, dst, color) int *pxy; struct mfdb *src, *dst; {
  434.     struct mfdb **p;
  435.     p = &ct7;
  436.     *p++ = src;
  437.     *p = dst;
  438.     ii0 = mode;
  439.     ii1 = color;
  440.     ii2 = 0;
  441.     vdi2 = pxy;
  442.     vdc(121, 4, 3, 0, h);    
  443.     vdi2 = &pi0;
  444. }
  445.  
  446. vr_trnfm(h, src, dst) struct mfdb *src, *dst; {
  447.     struct mfdb **p;
  448.     p = &ct7;
  449.     *p++ = src;
  450.     *p = dst;
  451.     vdc(110, 0, 0, 0, h);
  452. }
  453.  
  454. vq_color(h, index, set_flag, rgb) short rgb[]; {
  455.     /* inquire color representation */
  456.     ii0 = index;    /* color to enquire about */
  457.     ii1 = set_flag;    /* 0 = values set; 1 = values realized */
  458.     vdc(26, 0, 2, 0, h);
  459.     rgb[0] = io1;    /* red intensity - .1% */
  460.     rgb[1] = io2;    /* green intensity  */
  461.     rgb[2] = io3;    /* blue intensity */
  462. }
  463.  
  464. vs_color(h, index, rgb) short rgb[]; {    /* set color representation */
  465.     ii0 = index;
  466.     ii1 = rgb[0];    /* red */
  467.     ii2 = rgb[1];    /* green */
  468.     ii3 = rgb[2];    /* blue */
  469.     vdc(14, 0, 4, 0, h);
  470. }
  471.  
  472. vq_key_s(h, status) int h, *status; {
  473.     ct0 = 128;
  474.     ct1 = ct2 = ct3 = 0;
  475.     ct6 = h;
  476.     vdi();
  477.     *status = io0;
  478. }
  479.  
  480. /* mouse functions */
  481.  
  482. v_show_c(h, mstyle) {    /* show mouse */
  483.     ii0 = mstyle;
  484.     vdc(122, 0, 1, 0, h);
  485. }
  486.  
  487. v_hide_c(h) {    /* hide mouse */
  488.     vdc(123, 0, 0, 0, h);
  489. }
  490.  
  491. vsc_form(h, form) struct vdi_form *form; { /* define mouse shape */
  492.     vdi1 = form;
  493.     vdc(111, 0, 37, 0, h);
  494.     vdi1 = &ii0;
  495. }
  496.  
  497. vq_mouse(h, pstatus, px, py) short *pstatus, *px, *py; {
  498.     /* get mouse's status */
  499.     vdc(124, 0, 0, 0, h);
  500.     *pstatus = io0;
  501.     *px = po0;
  502.     *py = po1;
  503. }
  504.  
  505. vdi_attr(h, op, attr) { /* implements many common routines */
  506.     ii0 = attr;
  507.     vdc(op, 0, 1, 0, h);
  508.     return io0;
  509. }
  510.  
  511. /* GEM application init and exit */
  512.  
  513. appl_init() {
  514.     ct0 = 10;
  515.     ct2 = 1;
  516.     ct1 = ct3 = ct4 = 0;
  517.     aes();
  518.     return io0;
  519. }
  520.  
  521. appl_exit(i) { trap(1, TERM, i); }
  522.  
  523. /* VDI routines for the GEM library */
  524.  
  525. vq_extnd(handle, owflag, out) int *out; {
  526.     int i, j, *intout, *ptsout;
  527.     ct0 = 102;
  528.     ct1 = 0;
  529.     ct3 = 1;
  530.     ct6 = handle;
  531.     ii0 = owflag;
  532.     vdi();
  533.     intout = &io0;
  534.     for (i = 0; i < 45; i++) out[i] = intout[i];
  535.     ptsout = &po0;
  536.     for (j = 0; j < 12; j++) out[i++] = ptsout[j];
  537. }
  538.  
  539. /* 
  540.  * GEM:VDI set clipping rectangle 
  541.  *    flag = 0     no clipping
  542.  *    flag = 1    clipping on
  543.  *     pxy[] should contain the upper left and bottom right coords
  544.  */
  545.  
  546. vs_clip(handle, flag, pxy) int *pxy; {
  547.     ct0 = 129;
  548.     ct1 = 2;
  549.     ct3 = 1;
  550.     ct6 = handle;
  551.     ii0 = flag;
  552.     vdi2 = pxy;
  553.     vdi();
  554.     vdi2 = &pi0;
  555. }
  556.  
  557. /* GEM:VDI put justified text on the screen */
  558.  
  559. v_justified(handle, x, y, string, len, wspace, cspace) char *string; {
  560.     int *ip;
  561.     ct0 = 11;
  562.     ct1 = 2;
  563.     ct6 = handle;
  564.     ii0 = wspace;
  565.     ii1 = cspace;
  566.     ip = &ii2;
  567.     for (ct3 = 2; *ip++ = *string++; ct3++)
  568.         ;
  569.     pi0 = x;
  570.     pi1 = y;
  571.     pi2 = len;
  572.     vdi();
  573. }
  574.  
  575. /* AES: resource handling */
  576.  
  577. rsrc_gaddr(type, index, addr) long **addr; {
  578.     ct0 = 112;
  579.     ct1 = 2;
  580.     ct2 = ct4 = 1;
  581.     ct3 = 0;
  582.     ii0 = type;
  583.     ii1 = index;
  584.     aes();
  585.     *addr = ao0;
  586.     return io0;
  587. }
  588.  
  589. rsrc_saddr(type, index, addr) long *addr; {
  590.     ct0 = 113;
  591.     ct1 = 2;
  592.     ct2 = ct3 = 1;
  593.     ct4 = 0;
  594.     ii0 = type;
  595.     ii1 = index;
  596.     ai0 = addr;
  597.     aes();
  598.     return io0;
  599. }
  600.  
  601. /* graphics handling */
  602.  
  603. graf_handle(wchar, hchar, wbox, hbox) int *wchar, *hchar, *wbox, *hbox; {
  604.     ct0 = 77;
  605.     ct2 = 5;
  606.     ct1 = ct3 = ct4 = 0;
  607.     aes();
  608.     *wchar = io1;
  609.     *hchar = io2;
  610.     *wbox = io3;
  611.     *hbox = io4;
  612.     return io0;
  613. }
  614.  
  615. graf_rubberbox(x, y, minw, minh, lastw, lasth) int *lastw, *lasth; { 
  616.     ct0 = 70;
  617.     ct1 = 4;
  618.     ct2 = 3;
  619.     ct3 = ct4 = 0;
  620.     ii0 = x;
  621.     ii1 = y;
  622.     ii2 = minw;
  623.     ii3 = minh;
  624.     aes();
  625.     *lastw = io1;
  626.     *lasth = io2;
  627.     return io0;
  628. }
  629.  
  630. graf_dragbox(dw, dh, sx, sy, bx, by, bw, bh, endx, endy) int *endx, *endy; {
  631.     ct0 = 71;
  632.     ct1 = 8;
  633.     ct2 = 3;
  634.     ct3 = ct4 = 0;
  635.     ii0 = dw;
  636.     ii1 = dh;
  637.     ii2 = sx;
  638.     ii3 = sy;
  639.     ii4 = bx;
  640.     ii5 = by;
  641.     ii6 = bw;
  642.     ii7 = bh;
  643.     aes();
  644.     *endx = io1;
  645.     *endy = io2;
  646.     return io0;
  647. }
  648.  
  649. graf_movebox(w, h, sx, sy, dx, dy) {
  650.     ct0 = 72;
  651.     ct1 = 6;
  652.     ct2 = 1;
  653.     ct3 = ct4 = 0;
  654.     ii0 = w;
  655.     ii1 = h;
  656.     ii2 = sx;
  657.     ii3 = sy;
  658.     ii4 = dx;
  659.     ii5 = dy;
  660.     aes();
  661.     return io0;
  662. }
  663.  
  664. graf_growbox(bx, by, bw, bh, ex, ey, ew, eh) {
  665.     ct0 = 73;
  666.     ct1 = 8;
  667.     ct2 = 1;
  668.     ct3 = ct4 = 0;
  669.     aes2 = &bx;
  670.     aes();
  671.     aes2 = &ii0;
  672.     return io0;
  673. }
  674.     
  675. graf_shrinkbox(ex, ey, ew, eh, bx, by, bw, bh) {
  676.     ct0 = 73;
  677.     ct1 = 8;
  678.     ct2 = 1;
  679.     ct3 = ct4 = 0;
  680.     aes2 = &ex;
  681.     aes();
  682.     aes2 = &ii0;
  683.     return io0;
  684. }
  685.  
  686. graf_watchbox(tree, obj, instate, outstate) int *tree; { 
  687.     ct0 = 75;
  688.     ct1 = 4;
  689.     ct2 = ct3 = 1;
  690.     ct4 = 0;
  691.     ii1 = obj;
  692.     ii2 = instate;
  693.     ii3 = outstate;
  694.     ai0 = tree;
  695.     aes();
  696.     return io0;
  697. }
  698.  
  699. graf_slidebox(tree, parent, obj, vh) int *tree; { 
  700.     ct0 = 76;
  701.     ct1 = 3;
  702.     ct2 = ct3 = 1;
  703.     ct4 = 0;
  704.     ii0 = parent;
  705.     ii1 = obj;
  706.     ii2 = vh;
  707.     ai0 = tree;
  708.     aes();
  709.     return io0;
  710. }
  711.  
  712. graf_mouse(type, shape) int *shape; { 
  713.     ct0 = 78;
  714.     ct1 = ct2 = ct3 = 1;
  715.     ct4 = 0;
  716.     ii0 = type;
  717.     ai0 = shape;
  718.     aes();
  719.     return io0;
  720. }
  721.  
  722. graf_mkstate(x, y, mstate, kstate) int *x, *y, *mstate, *kstate; { 
  723.     ct0 = 79;
  724.     ct1 = ct3 = ct4 = 0;
  725.     ct2 = 5;
  726.     aes();
  727.     *x = io1;
  728.     *y = io2;
  729.     *mstate = io3;
  730.     *kstate = io4;
  731.     return io0;
  732. }
  733.  
  734. /* window handling */
  735.  
  736. wind_get(handle, gfld, gw1, gw2, gw3, gw4) int *gw1, *gw2, *gw3, *gw4; {
  737.     ct0 = 104;
  738.     ct1 = 2;
  739.     ct2 = 5;
  740.     ct3 = ct4 = 0;
  741.     ii0 = handle;
  742.     ii1 = gfld;
  743.     aes();
  744.     *gw1 = io1;
  745.     *gw2 = io2;
  746.     *gw3 = io3;
  747.     *gw4 = io4;
  748.     return io0;
  749. }
  750.  
  751. wind_create(kind, x, y, w, h) {
  752.     ct0 = 100;
  753.     ct1 = 5;
  754.     ct2 = 1;
  755.     ct3 = ct4 = 0;
  756.     ii0 = kind;
  757.     ii1 = x;
  758.     ii2 = y;
  759.     ii3 = w;
  760.     ii4 = h;
  761.     aes();
  762.     return io0;
  763. }
  764.  
  765. wind_set(handle, field, s1, s2, s3, s4) {
  766.     ct0 = 105;
  767.     ct1 = 6;
  768.     ct2 = 1;
  769.     ct3 = ct4 = 0;
  770.     ii0 = handle;
  771.     ii1 = field;
  772.     ii2 = s1;
  773.     ii3 = s2;
  774.     ii4 = s3;
  775.     ii5 = s4;
  776.     aes();
  777.     return io0;
  778. }
  779.  
  780. wind_open(handle, x, y, w, h) {
  781.     ct0 = 101;
  782.     ct1 = ct2 = 5;
  783.     ct3 = ct4 = 0;
  784.     ii0 = handle;
  785.     ii1 = x;
  786.     ii2 = y;
  787.     ii3 = w;
  788.     ii4 = h;
  789.     aes();
  790.     return io0;
  791. }
  792.  
  793. wind_close(handle) { 
  794.     ct0 = 102;
  795.     ct1 = ct2 = 1;
  796.     ct3 = ct4 = 0;
  797.     ii0 = handle;
  798.     aes();
  799.     return io0;
  800. }
  801.  
  802. wind_delete(handle) {
  803.     ct0 = 103;
  804.     ct1 = ct2 = 1;
  805.     ct3 = ct4 = 0;
  806.     ii0 = handle;
  807.     aes();
  808.     return io0;
  809. }
  810.  
  811. wind_find(x, y) {
  812.     ct0 = 106;
  813.     ct1 = 2;
  814.     ct2 = 1;
  815.     ct3 = ct4 = 0;
  816.     ii0 = x;
  817.     ii1 = y;
  818.     aes();
  819.     return io0;
  820. }
  821.  
  822. wind_update(n) {
  823.     ct0 = 107;
  824.     ct1 = ct2 = 1;
  825.     ct3 = ct4 = 0;
  826.     ii0 = n;
  827.     aes();
  828.     return io0;
  829. }
  830.  
  831. wind_calc(
  832.     type, kind, xi, yi, wi, hi, 
  833.     xo, yo, wo, ho) int *xo, *yo, *wo, *ho; {
  834.     ct0 = 108;
  835.     ct1 = 6;
  836.     ct2 = 5;
  837.     ct3 = ct4 = 0;
  838.     ii0 = type;
  839.     ii1 = kind;
  840.     ii2 = xi;
  841.     ii3 = yi;
  842.     ii4 = wi;
  843.     ii5 = hi;
  844.     aes();
  845.     *xo = io1;
  846.     *yo = io2;
  847.     *wo = io3;
  848.     *ho = io4;
  849.     return io0;
  850. }
  851.  
  852. /* event handling */
  853.  
  854. event_multi(
  855.   flags, clicks, mask, state, 
  856.   af, ax, ay, aw, ah,
  857.   bf, bx, by, bw, bh,
  858.   buff, lo, hi,
  859.   ox, oy, obut, ostate, okret, obret) 
  860.     int *ox, *oy, *obut, *ostate, *okret, *obret;
  861. {
  862.     ct0 = 25;
  863.     ct1 = 16;
  864.     ct2 = 7;
  865.     ct3 = 1;
  866.     ct4 = 0;
  867.     ii0 = flags;
  868.     ii1 = clicks;
  869.     ii2 = mask;
  870.     ii3 = state;
  871.     ii4 = af;
  872.     ii5 = ax;
  873.     ii6 = ay;
  874.     ii7 = aw;
  875.     ii8 = ah;
  876.     ii9 = bf;
  877.     ii10 = bx;
  878.     ii11 = by;
  879.     ii12 = bw;
  880.     ii13 = bh;
  881.     ii14 = lo;
  882.     ii15 = hi;
  883.     ai0 = buff;
  884.     aes();
  885.     *ox = io1;
  886.     *oy = io2;
  887.     *obut = io3;
  888.     *ostate = io4;
  889.     *okret = io5;
  890.     *obret = io6;
  891.     return io0;
  892. }
  893.  
  894. /* object handling */
  895.  
  896. objc_draw(tree, start, depth, xclip, yclip, wclip, hclip) int *tree; { 
  897.     ct0 = 42;
  898.     ct1 = 6;
  899.     ct2 = ct3 = 1;
  900.     ct4 = 0;
  901.     ii0 = start;
  902.     ii1 = depth;
  903.     ii2 = xclip;
  904.     ii3 = yclip;
  905.     ii4 = wclip;
  906.     ii5 = hclip;
  907.     ai0 = tree;
  908.     aes();
  909.     return io0;
  910. }
  911.  
  912. objc_find(tree, start, depth, x, y) int *tree; { 
  913.     ct0 = 43;
  914.     ct1 = 4;
  915.     ct2 = ct3 = 1;
  916.     ct4 = 0;
  917.     ii0 = start;
  918.     ii1 = depth;
  919.     ii2 = x;
  920.     ii3 = y;
  921.     ai0 = tree;
  922.     aes();
  923.     return io0;
  924. }
  925.  
  926. objc_offset(tree, object, xoff, yoff) int *tree, *xoff, *yoff; {
  927.     ct0 = 43;
  928.     ct1 = 1;
  929.     ct2 = 3;
  930.     ct3 = 1;
  931.     ct4 = 0;
  932.     ii0 = object;
  933.     ai0 = tree;
  934.     aes();
  935.     *xoff = io1;
  936.     *yoff = io2;
  937.     return io0;
  938. }
  939.  
  940. objc_edit(tree, object, ch, idx, kind, newidx) int *tree, *newidx; {
  941.     ct0 = 46;
  942.     ct1 = 4;
  943.     ct2 = 2;
  944.     ct3 = 1;
  945.     ct4 = 0;
  946.     ii0 = object;
  947.     ii1 = ch;
  948.     ii2 = idx;
  949.     ii3 = kind;
  950.     ai0 = tree;
  951.     aes();
  952.     *newidx = io1;
  953.     return io0;
  954. }
  955.  
  956. objc_change(tree, object, resvd, x, y, w, h, state, redraw) int *tree; {
  957.     ct0 = 47;
  958.     ct1 = 8;
  959.     ct2 = ct3 = 1;
  960.     ct4 = 0;
  961.     ii0 = object;
  962.     ii1 = resvd;
  963.     ii2 = x;
  964.     ii3 = y;
  965.     ii4 = w;
  966.     ii5 = h;
  967.     ii6 = state;
  968.     ii7 = redraw;
  969.     ai0 = tree;
  970.     aes();
  971.     return io0;
  972. }
  973.  
  974. /* menu handling */
  975.  
  976. menu_bar(tree, show) int *tree; { 
  977.     ct0 = 30;
  978.     ct1 = ct2 = ct3 = 1;
  979.     ct4 = 0;
  980.     ii0 = show;
  981.     ai0= tree;
  982.     aes();
  983.     return io0;
  984. }
  985.  
  986. menu_icheck(tree, item, check) int *tree; {
  987.     ct0 = 31;
  988.     ct1 = 2;
  989.     ct2 = ct3 = 1;
  990.     ct4 = 0;
  991.     ii0 = item;
  992.     ii1 = check;
  993.     ai0 = tree;
  994.     aes();
  995.     return io0;
  996. }
  997.  
  998. menu_enable(tree, item, enable) int *tree; {
  999.     ct0 = 32;
  1000.     ct1 = 2;
  1001.     ct2 = ct3 = 1;
  1002.     ct4 = 0;
  1003.     ii0 = item;
  1004.     ii1 = enable;
  1005.     ai0 = tree;
  1006.     aes();
  1007.     return io0;
  1008. }
  1009.  
  1010. menu_tnormal(tree, title, normal) int *tree; {
  1011.     ct0 = 33;
  1012.     ct1 = 2;
  1013.     ct2 = ct3 = 1;
  1014.     ct4 = 0;
  1015.     ii0 = title;
  1016.     ii1 = normal;
  1017.     ai0 = tree;
  1018.     aes();
  1019.     return io0;
  1020. }
  1021.  
  1022. menu_text(tree, item, text) int *tree; char *text; {
  1023.     ct0 = 34;
  1024.     ct1 = ct2 = 1;
  1025.      ct3 = 2;
  1026.     ct4 = 0;
  1027.     ii0 = item;
  1028.     ai0 = tree;
  1029.     ai1 = text;
  1030.     aes();
  1031.     return io0;
  1032. }
  1033.  
  1034. menu_register(id, string) char *string; {
  1035.     ct0 = 35;
  1036.     ct1 = ct2 = ct3 = 1;
  1037.     ct4 = 0;
  1038.     ii0 = id;
  1039.     ai0 = string;
  1040.     aes();
  1041.     return io0;
  1042. }
  1043.  
  1044. /* form handling */
  1045.  
  1046. form_pf(fmt, args) char *fmt; int args; {
  1047.     extern char _pfb[1];
  1048.     _dopf(_pfb, fmt, &args);
  1049.     form_alert(0, _pfb);
  1050. }
  1051.  
  1052. form_do(tree, start) int *tree; {
  1053.     ct0 = 50;
  1054.     ct1 = ct3 = 1;
  1055.     ct2 = 2;
  1056.     ct4 = 0;
  1057.     ii0 = start;
  1058.     ai0 = tree;
  1059.     aes();
  1060.     return io0;
  1061. }
  1062.  
  1063. form_dial(flag, sx, sy, sw, sh, bx, by, bw, bh) {
  1064.     ct0 = 51;
  1065.     ct1 = 9;
  1066.     ct3 = ct2 = 1;
  1067.     ct4 = 0;
  1068.     ii0 = flag;
  1069.     ii1 = sx;
  1070.     ii2 = sy;
  1071.     ii3 = sw;
  1072.     ii4 = sh;
  1073.     ii5 = bx;
  1074.     ii6 = by;
  1075.     ii7 = bw;
  1076.     ii8 = bh;
  1077.     aes();
  1078.     return io0;
  1079. }
  1080.  
  1081. form_center(tree, x, y, w, h) int *tree, *x, *y, *w, *h; {
  1082.     ct0 = 54;
  1083.     ct1 = 0;
  1084.     ct3 = 5;
  1085.     ct2 = 1;
  1086.     ct4 = 0;
  1087.     ai0 = tree;
  1088.     aes();
  1089.     *x = io1;
  1090.     *y = io2;
  1091.     *w = io3;
  1092.     *h = io4;
  1093.     return io0;
  1094. }
  1095.  
  1096. form_error(num) {
  1097.     ct0 = 53;
  1098.     ct1 = ct2 = 1;
  1099.     ct3 = ct4 = 0;
  1100.     ii0 = num;
  1101.     aes();
  1102.     return io0;
  1103. }
  1104.  
  1105. form_alert(button, string) char *string; {
  1106.     ct0 = 52;
  1107.     ct1 = ct2 = ct3 = 1;
  1108.     ct4 = 0;
  1109.     ii0 = button;
  1110.     ai0 = string;
  1111.     aes();
  1112.     return io0;
  1113. }
  1114.  
  1115. /* AES file selector */
  1116.  
  1117. fsel_input(dir, file, button) char *dir, *file; int *button; {
  1118.     ct0 = 90;
  1119.     ct1 = ct4 = 0;
  1120.     ct2 = ct3 = 2;
  1121.     ai0 = dir;
  1122.     ai1 = file;
  1123.     aes();
  1124.     *button = io1;
  1125.     return io0;
  1126. }
  1127.  
  1128. /* AES and VDI support routines */
  1129.  
  1130. aes() {
  1131.     /* 
  1132.          * load address of aes parameter block into a0
  1133.          * transfer a0 to d1
  1134.          * load 200 into d0
  1135.          * trap #2
  1136.          */
  1137.     asm( lag aes0 0   tad 0 1   ldw 200 0   trp 2 );
  1138. }
  1139.  
  1140. vdi() {
  1141.     /* 
  1142.          * load address of vdi parameter block into a0
  1143.          * transfer a0 to d1
  1144.          * load 115 into d0
  1145.          * trap #2
  1146.          */
  1147.     asm( lag vdi0 0   tad 0 1   ldw 115 0   trp 2 );
  1148. }
  1149.